import request from '@/utils/request'

// 获取商户
export function getMerchant(commercial = '01', floor = '全部楼层', page, size) {
  return request({
    url: 'store/findStore',
    method: 'POST',
    data: {
      commercialCode: commercial,
      storeFloor: floor,
      page,
      size
    }
  })
}

// 根据id获取商户数据详情
export function getShopDetail(id) {
  return request({
    url: 'store/findById',
    method: 'POST',
    data: {
      id
    }
  })
}

// 获取商户全部分类
export function getShopType() {
  return request({
    url: 'commercial/getId',
    method: 'GET'
  })
}

export function pay(storeId, openId, totalFee, couponCodeList) {
  return request({
    url: 'wxpay/pay',
    method: 'POST',
    data: {
      storeId,
      openId,
      totalFee,
      couponCodeList
    }
  })
}

export function recordPay(storeId, openId, count, totalFee, outTradeNo) {
  return request({
    url: 'order/submit',
    method: 'POST',
    data: {
      storeId,
      openId,
      count,
      totalFee,
      outTradeNo
    }
  })
}

// 搜索商户
export function searchShop(brandsName) {
  return request({
    url: 'store/findByName',
    method: 'POST',
    data: {
      brandsName
    }
  })
}

// 收藏商铺
export function collectionStore(userId, storeId) {
  return request({
    url: 'store/storeUp',
    method: 'POST',
    data: {
      userId,
      storeId
    }
  })
}

// 查询收藏商铺
export function queryCollectionStore(userId) {
  return request({
    url: 'store/query_storeUp',
    method: 'POST',
    data: {
      userId
    }
  })
}

// 优惠券推荐接口
export function recommandCoupon(price, storeId, openId) {
  return request({
    url: 'coupon/recommand',
    method: 'POST',
    data: {
      price,
      storeId,
      openId
    }
  })
}

// 微信购买优惠券接口
export function buyCoupon(openId, storeId, totalFee, couponIdList) {
  return request({
    url: 'wxpay/payCoupon',
    method: 'POST',
    data: {
      openId,
      storeId,
      totalFee,
      couponIdList
    }
  })
}

// 获取现有优惠券
export function getUserValidCode(openId, price, storeId) {
  return request({
    url: 'coupon/getUserValidCode',
    method: 'POST',
    data: {
      openId,
      price,
      storeId
    }
  })
}

// 获取现有渠道券
export function getUserFreeCode(openId, storeId, price) {
  return request({
    url: 'coupon/getUserFreeCode',
    method: 'POST',
    data: {
      openId,
      storeId,
      price
    }
  })
}

// 领取商家联单活动券
export function getCouponByStore(userId, storeId) {
  return request({
    url: 'jointOrder/getCouponByStore',
    method: 'POST',
    data: {
      userId,
      storeId
    }
  })
}

// 推荐联单活动券
export function recommendStoreCoupon(userId) {
  return request({
    url: 'jointOrder/recommendStoreCoupon',
    method: 'POST',
    data: {
      userId
    }
  })
}

// 支付订单
export function getPayOrder(openId, storeId, payAmount) {
  return request({
    url: 'wxpay/order',
    method: 'POST',
    data: {
      openId,
      storeId,
      payAmount
    }
  })
}

// 支付订单
export function getZfbPayOrder(zfbId, storeId, payAmount) {
  return request({
    url: 'wxpay/order',
    method: 'POST',
    data: {
      zfbId,
      storeId,
      payAmount
    }
  })
}

// 购买爆款
export function payProducts(openId, totalFee, goodsId, count) {
  return request({
    url: 'wxpay/payProducts',
    method: 'POST',
    data: {
      openId,
      totalFee,
      goodsId,
      count
    }
  })
}

export function aliPay(zfbId, storeId, totalFee) {
  return request({
    url: 'alipay/ali_pay',
    method: 'POST',
    data: {
      zfbId,
      storeId,
      totalFee
    }
  })
}

// export function aliPay(zfbId, storeId, totalFee) {
//   return request({
//     url: 'alipay/pay',
//     method: 'POST',
//     data: {
//       zfbId,
//       storeId,
//       totalFee
//     }
//   })
// }
